package mapper_1;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import pojo.Category;

import java.util.List;


//音乐的分类
public interface CategoryMapper {


//    根据id 查找我们的所有列
    // 需要封装 我们的id  和 对应的分类名字
    @Select("SELECT  * from tb_category where id=#{id}")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(id=true,column = "category_name",property = "categoryName")
    })
    public Category findCategoryById(int id);


    //2420710103_刘小文
    //    关联关系注解根据类别查询 类别  及所关联的音乐信息。
    @Select("SELECT  * from tb_category where id=#{id}")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(id=true,column = "category_name",property = "categoryName"),
            @Result(
                  column = "id",
                    property = "musicList",
                    javaType = List.class,
                    many = @Many(select="mapper_1.MusicMapper.findMusicByc_id")
            )
    })
    // 需要传入我们类型的   id  1-5 之间
    public Category findCatAndMusicById(int id);


}
